.global loader                          # making entry point visible to linker
.global _isr_wrapper

# setting up the Multiboot header - see GRUB docs for details
.set ALIGN,    1<<0                     # align loaded modules on page boundaries
.set MEMINFO,  1<<1                     # provide memory map
.set FLAGS,    ALIGN | MEMINFO          # this is the Multiboot 'flag' field
.set MAGIC,    0x1BADB002               # 'magic number' lets bootloader find the header
.set CHECKSUM, -(MAGIC + FLAGS)         # checksum required

.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM

# reserve initial kernel stack space
.set STACKSIZE, 0x4000                  # that is, 16k.
.comm stack, STACKSIZE, 32              # reserve 16k stack on a quadword boundary

loader:
    
    mov $0x08, %ebx
    mov %ebx, %ds
    mov %ebx, %es
    mov %ebx, %fs
    mov %ebx, %ss

    # This does not work and I am not sure why. So I set my stack up elsewhere and it works fine
    #mov   $(stack + STACKSIZE), %esp    # set up the stack
    #push  %eax                          # Multiboot magic number
    #push  %ebx                          # Multiboot data structure

    #mov $0x00, %eax
    mov $0x00, %ebx
    #mov $_isr_wrapper, %ebx
    mov $0x00200000, %esp
    push %eax
    push %eax

    call $0x10, $kmain
    
    cli

hang:
    hlt                                 # halt machine should kernel return
    jmp   hang
    
#_isr_wrapper:
#    pusha
#    #call $0x10, $interrupt_handler
#    popa
#    iret
 
 
    
    
    
    
    
 